import Map from 'ol/Map';
import OSM from 'ol/source/OSM';
import TileLayer from 'ol/layer/Tile';
import View from 'ol/View';

var map = new Map({
  layers: [
    new TileLayer({
      source: new OSM(),
    }) ],
  target: 'map',
  view: new View({
    center: [0, 0],
    zoom: 2,
  }),
});

function onClick(id, callback) {
  document.getElementById(id).addEventListener('click', callback);
}
onClick('zoom-out',function () {
  var view = map.getView();
  var zoom = view.getZoom();
  view.setZoom(zoom - 1);
});

onClick('zoom-in',function () {
  var view = map.getView();
  var zoom = view.getZoom();
  view.setZoom(zoom + 1);
});